import java.util.HashMap;
/**
 * Class for any character in the game. allows for inventory management and general statistics (health, name, etc.)
 * 
 * @author Leander & Laurens
 * @version 6-1-2014
 */
public class Character
{
    // instance variables - replace the example below with your own
    protected Room currentRoom;
    protected HashMap<String, Item> inventory;
    
    protected String name;
    protected int health;
    
    protected String text;

    /**
     * Constructor for objects of class Character
     * @param name The name of the Character
     * @param health The amount of health this character has
     */
    public Character(String name, int health, Room startRoom)
    {
        this.name = name;
        this.health = health;
        this.currentRoom = startRoom;
        
        inventory = new HashMap<String, Item>();
    }

    //PUBLIC FUNCTIONS
    
    /**
     * Adds an item to the inventory
     * @param item The item to add
     */
    public void addItem(Item item)
    {
        String name = item.getName();
        inventory.put(item.getName(), item);
    }
    
    /**
     * Check if the Character has an item by a certain name
     * @param itemName The name of the item to check for.
     */
    public boolean hasItem(String itemName)
    {
        return inventory.containsKey(itemName);
    }
    
    /**
     * Get an item from the player's inventory
     * @param itemName the name of the item to get
     */
    public Item getItem(String itemName)
    {
        return inventory.get(itemName);
    }
    
    /**
     * Remove an item from the character's inventory
     * @param itemName The name of the item to remove
     */
    public void removeItem(String itemName)
    {
        inventory.remove(itemName);
    }
    
    /**
     * Print an overview containing the name and weight of every item in the character's inventory
     */
    public String getItemOverview()
    {
        String itemOverview = "";
        for(String currentItem : inventory.keySet())
        {
            itemOverview = itemOverview + inventory.get(currentItem).getName() + " " + inventory.get(currentItem).getWeight() + "\n";
        }
        
        return itemOverview;
    }
    
    /**
     * Returns a standard line a character gives when talked to.
     */
    public String talk()
    {
        return "blah";
    }
    
    /**
     * reduce the health of a character
     * @param amountOfDamage The amount of damage a character takes.
     */
    public void takeDamage(int amountOfDamage)
    {
        this.health = health - amountOfDamage;
    }
    
    
    // GETTERS
    /**
     * Returns the name of the character
     */
    public String getName()
    {
        return name;
    }
    
    /**
     * returns the health of the character
     */
    public int getHealth()
    {
        return health;
    }
    
    /**
     * Returns the room that the character is currently in.
     */
    public Room getCurrentRoom()
    {
        return currentRoom;
    }
    
    /**
     * Get the description of an item in the character's possession
     * @param itemName The name of the item to get a description for
     */
    public String getItemDescription(String itemName)
    {
        return inventory.get(itemName).getDescription();
    }
    
    /**
     * Get the strength of an item in the character's possession
     * @param itemName The name of the item
     */
    public int getItemStrength(String itemName)
    {
        return inventory.get(itemName).getStrength();
    }
    
    /**
     * Get the weight of an item in the player's possession
     * @param itemName the name of the item
     */
    public int getItemWeight(String itemName)
    {
        return inventory.get(itemName).getWeight();
    }
    
    //SETTERS
    
    /**
     * Set the character's current room
     * @param nextRoom The room to move this character to.
     */
    public void setCurrentRoom(Room nextRoom)
    {
        currentRoom = nextRoom;
    }
}
